<?php
require_once APPPATH."controllers/cms_template.php";
/**
 *
 * @author Tri Ngo Minh <minhtri2711@gmail.com>
 *
 */
class cms_home_template extends cms_template {

    function __construct() {
        parent::__construct();
		$this->_template_type = 'home';
		$this->load->model('Model_newsgroup', 'model_newsgroup');
		$this->load->model('Model_datagroup', 'model_datagroup');
    }

	/**
	 *
	 *
	 */
    function add($level = 1, $nav_id = 0){
		 if ($this->input->post('Submit')) {
			// Serialize t1
			$t1 = parse_input("t1_", $_POST);
			$t2 = parse_input("t2_", $_POST);
			$t3 = parse_input("t3_", $_POST);
			$_POST['item_t1'] = serialize($t1);
			$_POST['item_t2'] = serialize($t2);
			$_POST['item_t3'] = serialize($t3);
		 }
		 else{
		 	$this->_assign['newsgroups'] = $this->model_newsgroup->fetch_all();
		 	$this->_assign['datagroups'] = $this->model_datagroup->fetch_all();
		 }
		 return parent::add($level, $nav_id);
    }

	/**
	 *
	 *
	 */
    function edit($level = 1, $nav_id = 0, $id = 0){
    	if ($this->input->post('Submit')) {
			// Serialize t1
			$t1 = parse_input("t1_", $_POST);
			$t2 = parse_input("t2_", $_POST);
			$t3 = parse_input("t3_", $_POST);
			$_POST['item_t1'] = serialize($t1);
			$_POST['item_t2'] = serialize($t2);
			$_POST['item_t3'] = serialize($t3);
		 }
		 else{
		 	$this->_assign['newsgroups'] = $this->model_newsgroup->fetch_all();
		 	$this->_assign['datagroups'] = $this->model_datagroup->fetch_all();
		 }
		 parent::edit($level, $nav_id, $id);
    }
}
?>
